
const state = {
  // 设置属性
 queryData:[],//首页内容展示静态
compareData:[]
}

const getters = {
  // 获取属性的状态
  getQueryData: state => state.queryData,
  // getCompareData: state => state.compareData,
  getCompareData:function(state){
    return state.compareData
  }

}

const mutations = {
  // 改变属性的状态
  setQueryData(state,data){
    // data.Data.forEach((item)=>{
    //   state.compareData.forEach((item2)=>{
    //     if(item.Id===item2.Id){
    //       item.selected=true
    //     }else {
    //       item.selected=false
    //     }
    //   })
    // })
    // localStorage.setItem('queryData', JSON.stringify(data))
    // console.log(JSON.parse(localStorage.queryData))
    state.queryData=data
  },
    // 将匹配到对象,compareData 删除
    removeCompareItems(state,data){
    if(data=='clearAll'){
      state.compareData=[]
      state.queryData.Data.forEach((item)=>{
          item.selected=false
      })
    }else {
      state.compareData.forEach((item,index) => {
        if(item == data){
          state.compareData.splice(index,1)
        }
      });
    }

    },
    // 新添加
    pushToCompareItems(state,data){
      state.compareData.push(data)
    }



}

const actions = {

}

export default{
  state,
  getters,
  mutations,
  actions
}
